<?php
declare (strict_types = 1);
namespace app\course\model\base;

use app\common\model\BaseModel;
use app\exam\model\{Paper};
use think\model\relation\BelongsTo;

/**
 * 定义课程考试数据模型
 */
class CourseExamLink extends BaseModel
{
    /**
     * 表名
     * @var string
     */
    protected $name = 'course_exam_link';

    /**
     * 定义字段类型
     * @var array
     */
    protected $type = [
        'id'        => 'integer',
        'paper_id'  => 'integer',
        'course_id' => 'integer',
    ];

    /**
     * 关联试卷
     */
    public function paperBase(): BelongsTo
    {
        return $this->belongsTo(Paper::class, 'paper_id', 'id')->bind([
            'paper_title'   => 'title',
            'exam_number',
        ]);
    }

}
